package com.cskaoyan.service;

import com.cskaoyan.dao.OrderDao;
import com.cskaoyan.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


//@Component("service") //value属性指定组件id为：service
@Component              //默认的组件id为类型的首字母小写：userServiceImpl
public class UserServiceImpl implements UserService{

    @Autowired
    @Qualifier("userDaoImpl1")  //使用@Autowired+@Qualifier来指定组件id
    UserDao userDao1;
    @Resource(name = "userDaoImpl2")
    UserDao userDao2;
    @Autowired       //默认按照类型来注入，要求该类型的组件只有一个
    OrderDao orderDao;
    //@Value("songge")
    @Value("${param.username}")
    String username;

    @Override
    public void sayHello() {
        userDao1.hello();
        userDao2.hello();
        orderDao.order();
        System.out.println(username);
    }
}
